package leetcode.offer;

import org.junit.Test;

import java.util.HashSet;
import java.util.Set;

/**
 * @author LiDong
 * @version 1.0.0
 * @createTime 2021/11/12
 */
public class offer03 {


    @Test
    public void test() {
       int[] array = {2, 3, 1, 0, 2, 5, 3};
        System.out.println(findRepeatNumber(array));
    }

    public int findRepeatNumber(int[] nums) {
        Set<Integer> set = new HashSet<>();
        for (int num : nums) {
            if(set.contains(num)){
                return num;
            }else{
                set.add(num);
            }
        }
        return 0;
    }
}
